#include<iostream>
#include<string>
#define MaxSize 50
using namespace std;
typedef struct{
	char data[MaxSize];
	int length;
} SqString;
void StrAssign(SqString* &str,char s[]);
int main()
{
	SqString *str,*t;
	str=new SqString;
	t=new SqString;
	str->length=0;
	int i,j,n,m,begin=0,flag=1,cnt=0,max=0;
	char s[MaxSize],st[MaxSize];
	cin>>s;
	StrAssign(str,s);
	cin>>st;
	StrAssign(t,st);
	for(i=0;i<str->length;i++){
		for(j=0;j<t->length;j++){
			if(str->data[i]==t->data[j]){
				n=i;m=j;
				while(str->data[n]==t->data[m]){
					cnt++;n++;m++;
					if(str->data[n]=='\0'||t->data[m]=='\0')break;
				}
				if(cnt>max){
					max=cnt;begin=i;
				}cnt=0;
			}
		}
	}
	if(max==0)cout<<"NULL";
	else
		for(i=begin;i<max+begin;i++){
			cout<<str->data[i];
		}
}
void StrAssign(SqString* &str,char s[])
{
	int i;
	for(i=0;s[i];i++){
		str->data[i]=s[i];
	}str->length=i;
}
